NFC
The NFC sensor is positioned under OLEM between the two front wheels. It can be used to read data from tags when going over them. When NFC detection is enabled, OLEM reads any tag he comes across and stores its data, which can then be read using the API below.
- Only the last tag detected is kept: if a new tag is detected before the previous one is read with
nfc_get_card_data(), it replaces it. - The data of a tag is read as text.
- Currently, only tags NTAG type 2 are supported (ISO/IEC 14443A). They are generally sold as NTAG2xx.
Example
The data of each tag OLEM goes over is printed, until a hand is above the top sensor.
import olem
olem.nfc_enable()
while not olem.ir_top_is_hand_present():
if olem.nfc_get_number_of_cards_waiting() > 0:
data = olem.nfc_get_card_data()
print(data)
olem.delay_ms(50)
olem.nfc_disable()
Functions
nfc_enable()
Start detecting NFC tags. The reader is under OLEM, between the front wheels. Only NTAG type 2 tags (ISO/IEC 14443A, sold as NTAG2xx) are supported.
nfc_disable()
Stop detecting NFC tags.
nfc_is_enabled()
Returns: True if NFC detection is enabled, False otherwise
nfc_get_number_of_cards_waiting()
Returns: number of detected tags that were not read yet with nfc_get_card_data()
nfc_get_card_data()
Get the data of the oldest detected tag that was not read yet.
Returns: text stored on the tag, or an empty string if there is no tag waiting